package com.dingli.admin.service.impl;


import com.dingli.admin.service.InsertBank;
import com.dingli.framework.entity.Bank;
import com.dingli.framework.mapper.BankMapper;
import com.dingli.framework.util.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class InsertBankImpl implements InsertBank {
    @Autowired
    private BankMapper bankMapper;
    @Override
    public Response insertBanK(String bankName, String shortName,Date establishDate) {
        List<Bank> bank =bankMapper.getBank(bankName);
        if (bank.size() != 0) {
            return new Response(500, "用户已存在");
        } else {
            int i = bankMapper.insertBank(bankName,shortName,establishDate);
            if (i == 0) {
                return new Response(500, "添加失败");
            }
            return new Response(200, "添加成功", i);
        }
    }
}